Skip to content

feat(executor): use the exact VersionedConstants as specified in the Header and BlockEnv#163

Merged
kariy merged 1 commit intomainfrom
versioned-constnat
Jul 7, 2025
Merged

feat(executor): use the exact VersionedConstants as specified in the Header and BlockEnv#163
kariy merged 1 commit intomainfrom
versioned-constnat

Conversation

@kariy
Copy link
Member

@kariy kariy commented Jul 7, 2025

No description provided.

@claude
Copy link
Contributor

claude bot commented Jul 7, 2025

Claude finished @kariy's task —— View job


PR Review Complete

Todo List

  • Read and analyze changed files
  • Evaluate code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Review security concerns
  • Evaluate test coverage
  • Provide comprehensive review feedback

Summary

This PR improves the executor by using the exact VersionedConstants specified in block headers and environments, rather than relying on hardcoded versions. The changes enhance version consistency and fix L2 gas price handling.

Code Quality & Best Practices ✅

Strengths:

  • Proper version handling: Now uses the actual Starknet version from block headers instead of hardcoded V0_13_4
  • L2 gas price fix: Correctly uses l2_gas_prices instead of the previous placeholder using l1_gas_price
  • Consistent versioning: Added proper TryFrom implementation for version conversion
  • Clear documentation: Updated comments to reflect the actual behavior

Minor improvements:

  • The cfg_env field addition follows good design patterns by storing necessary configuration
  • Error handling with InvalidVersionError is well-implemented

Potential Issues & Bugs 🟡

Medium Priority:

  1. Version compatibility (crates/primitives/src/version.rs:134): There's a potential mapping issue where [0, 13, 1, 1] maps to V0_13_3 instead of a more intuitive mapping. This should be verified against Starknet's actual versioning.

  2. Error handling (crates/executor/src/implementation/blockifier/mod.rs:191): The .expect("valid version") could cause panics if an invalid version is encountered. Consider returning a Result type instead.

Low Priority:
3. Code duplication: The versioned constants override logic is duplicated between mod.rs:197-199 and utils.rs:487-489. Consider extracting this into a helper function.

Performance Considerations ✅

Positive impacts:

  • Eliminates unnecessary cloning by using the appropriate version-specific constants
  • More efficient gas price handling by using actual values instead of placeholders

No concerns:

  • The version lookup via VersionedConstants::get() is likely cached/optimized
  • Additional struct field has minimal memory overhead

Security Concerns ✅

No significant security issues found:

  • Version validation prevents invalid versions from being used
  • The changes maintain existing access controls and validation patterns
  • Configuration overrides are properly documented as potentially affecting snos compatibility

Test Coverage ⚠️

Missing tests for:

  • Version conversion edge cases in the new TryFrom implementation
  • Error handling when invalid versions are encountered
  • The new L2 gas price handling logic

Recommendation: Add tests for:

#[test]
fn test_version_conversion_edge_cases() {
    // Test invalid versions
    // Test boundary versions
}

#[test]
fn test_l2_gas_price_handling() {
    // Test proper L2 gas price assignment
}

Overall Assessment

This is a solid improvement that addresses important technical debt. The changes enhance version consistency and fix gas price handling issues. The code quality is good with proper error handling and documentation.

Recommendation: Approve with minor suggestions

The changes are ready for merge after addressing the version mapping verification and considering the error handling improvements.

"Accept the things to which fate binds you, and love the people with whom fate brings you together."
- Marcus Aurelius, Meditations

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Binary size report 📊

Branch Size
main 64.08MiB
versioned-constnat 64.09MiB ( +0.01% )

@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 56.86275% with 22 lines in your changes missing coverage. Please review.

Project coverage is 72.34%. Comparing base (9bde0ae) to head (103a022).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
crates/primitives/src/version.rs 18.51% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #163      +/-   ##
==========================================
- Coverage   73.32%   72.34%   -0.99%     
==========================================
  Files         209      219      +10     
  Lines       23132    24180    +1048     
==========================================
+ Hits        16961    17492     +531     
- Misses       6171     6688     +517     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kariy kariy merged commit e305f2a into main Jul 7, 2025
11 of 13 checks passed
@kariy kariy deleted the versioned-constnat branch July 7, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant